{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "099ffd9d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# python的输入函数input（）\n",
    "### 1.作用--->接收来自用户的输入\n",
    "### 2.返回值类型---->输入值得类型为str\n",
    "### 3.值的存储---->使用=对输入的值进行存储"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1dfaa882",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "what are you doing?eating\n",
      "eating <class 'str'>\n"
     ]
    }
   ],
   "source": [
    "a=input(\"what are you doing?\")\n",
    "print(a,type(a))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "affc0f15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个加数:3\n",
      "请输入另一个加数:4\n",
      "34\n"
     ]
    }
   ],
   "source": [
    "a=input('请输入一个加数:')\n",
    "b=input('请输入另一个加数:')\n",
    "print(a+b)\n",
    "# 类型转换，如果需要整数型和浮点型，就需要将str类型通过int（）函数\n",
    "# 或者float（）函数进行类型转换"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a6f131da",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个加数:3\n",
      "请输入另一个加数:4\n",
      "<class 'int'> <class 'int'>\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "a=input('请输入一个加数:')\n",
    "a=int(a)#将转换之后的结果存储到a中\n",
    "b=input('请输入另一个加数:')\n",
    "b=int(b)\n",
    "print(type(a),type(b))\n",
    "print(a+b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "fec4102a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入一个加数:3\n",
      "请输入另一个加数:4\n",
      "<class 'int'> <class 'int'>\n",
      "7\n"
     ]
    }
   ],
   "source": [
    "#这样还是有些麻烦，有些累赘，所以直接在此处转换就好了\n",
    "a=int(input('请输入一个加数:'))\n",
    "# a=int(a)#将转换之后的结果存储到a中\n",
    "b=int(input('请输入另一个加数:'))\n",
    "# b=int(b)\n",
    "print(type(a),type(b))\n",
    "print(a+b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d2bc0a81",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
